package dwarffortess.web.research;

import java.util.prefs.Preferences;
import java.io.File;

public class PrefTools {

    public static String getResearcherVersion() {
       return System.getProperty("DF.Researcher.version", "Development");
    }


    public static File getDFPath() {
        String path = getDFPathString();
        if (null == path) {
            return null;
        }
        File result = new File(path);
        if (!FileLayoutTools.isDFDirectory(result)) {
            return null;
        }
        return result;
    }

    public static String getDFPathString() {
        Preferences preferences = getPreferences();
        return preferences.get("DFPath", null);
    }

    public static String getLastFilechooserPathString() {
        Preferences preferences = getPreferences();
        return preferences.get("FileChooserPath", null);
    }

    public static void setLastFilechooserPathString(String path) {
        Preferences preferences = getPreferences();
        preferences.put("FileChooserPath", path);
    }


    public static void setDFPath(String path) {
        Preferences preferences = getPreferences();
        preferences.put("DFPath", path);
    }

    private  static Preferences getPreferences() {
        return Preferences.userRoot().node("denspb.spb.ru/DwarfFortess/Research");
    }

}
